//
// Created by Semir on 2020/4/23.
//

#include <iostream>
#include <algorithm>

using namespace std;

const int MAX_N = 25;
int n;
string arr[MAX_N];

bool cmp(string a, string b) {
    if (a.length() == b.length()) {
        return a > b;
    }
    return a + b > b + a;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    sort(arr, arr + n, cmp);
    for (int i = 0; i < n; i++) {
        cout << arr[i];
    }
    return 0;
}